﻿(function() {
        var saveCmd = {
                readOnly: 1,
                exec: function( editor ) {
                        if ( editor.fire( 'save' ) ) {
                                var data=editor.getData();
								if(!data || data.length<1){
									alert("当前设计器没有内容，不能执行保存动作！");
									return;
								}
								var url = location.href;  
								var params = url.substring(url.indexOf("?"),url.length);
								$.ajax({
									url:contextPath+"/dorado/uflo/form/save"+params,
									data:{
										content:data,
										name:"test"
									},
									type:"POST",
									success:function(){
										alert("保存成功！");
									},
									error:function(req,error,exception){
										alert("保存失败！");
									}
								});
                        }
                }
        };

        var pluginName = 'save';

        // Register a plugin named "save".
        CKEDITOR.plugins.add( pluginName, {
                lang: 'zh-cn', 
                icons: 'save',
                hidpi: true,
                init: function( editor ) {
                        // Save plugin is for replace mode only.
                        if ( editor.elementMode != CKEDITOR.ELEMENT_MODE_REPLACE )
                                return;

                        var command = editor.addCommand( pluginName, new CKEDITOR.dialogCommand(pluginName));
						CKEDITOR.dialog.add( pluginName, this.path + 'dialogs/save.js');
                        editor.ui.addButton( 'Save', {
                                label: editor.lang.save.toolbar,
                                command: pluginName,
                                toolbar: 'clipboard,1'
                        });
                }
        });
})();